package com.yztc.yidoutang.activity.quanwu_activity;

import com.yztc.yidoutang.bean.QuanWuBean;
import com.yztc.yidoutang.http.HttpHelper;
import com.yztc.yidoutang.http.QuanWuService;

import java.util.Map;

import retrofit2.Retrofit;
import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by My on 2016/10/18.
 */

public class QuanWuModel implements QuanWuContract.Model {

    @Override
    public void getQuanWuData(Map<String, String> params, final QuanWuContract.OnLoadQuanWuListener loadQuanWuListener) {
        Retrofit retrofit= HttpHelper.getInstance().getRetrofit();
        Observable<QuanWuBean> observable=retrofit.create(QuanWuService.class).getQuanWuList(params);
        observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<QuanWuBean>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(QuanWuBean quanWuBean) {
                loadQuanWuListener.onSuccess(quanWuBean);
            }
        });
    }
}
